package com.xianyun.book.service;

import com.alibaba.cola.catchlog.CatchAndLog;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.alibaba.cola.extension.BizScenario;
import com.xianyun.book.api.SystemUserServiceI;
import com.xianyun.book.command.UserRegisterCmdExe;
import com.xianyun.book.common.constant.BizCode;
import com.xianyun.book.dto.UserRegisterCmd;
import com.xianyun.book.dto.UserUpdateCmd;
import com.xianyun.book.dto.clientobject.SystemUserCO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * @author ytt
 */
@Slf4j
@CatchAndLog
@Validated
@Service
public class SystemUserServiceImpl implements SystemUserServiceI {

    @Resource
    private UserRegisterCmdExe saveCmdExe;

    @Override
    public Response registerUser(@Valid UserRegisterCmd registerCmd) {
        BizScenario scenario = BizScenario.valueOf(registerCmd.getBizId(), BizCode.USE_CAUSE_REGISTER,registerCmd.getScenario());
        registerCmd.setBizScenario(scenario);
        return saveCmdExe.execute(registerCmd);
    }

    @Override
    public SingleResponse<SystemUserCO> getUserInfoBySecurityKey(String securityKey) {
        return null;
    }

    @Override
    public Response updateUserInfo(UserUpdateCmd updateCmd) {
        return null;
    }
}
